{template common/header}
{template store/showheader}
<div class="container mt10">
{template store/showside}
	<div class="span9 main ml10 mt10">
		<div class="store-comment">
			<div>
				<h2 class="mb10">{lang store_comment}</h2>
			</div>
			<div class="the-comment">
			<ol id="{$store["store_id"]}_storecomments" class="comments">
			</ol>
			<ol id="{$store["store_id"]}_commentbox" class="comments clearfix">
				<li class="response" style="display: list-item; ">
					<h5>
						<a href="javascript:void(0);"><img class="avatar photo-32" src="{avatar($cuser['uid'], 'middle')}"> {if $islogin}$cuser['nickname']{else}{lang login_first}{/if}</a>
					</h5>
					<div class="comment-body">
						{template editor/reply_editor}
					</div>
					<p class="comment-meta pull-right mr10">
						<a href="javascript:void(0);" class="btn btn-puzz"  data-action="addStoreComment" data-params="{$store['store_id']},comment_store">{lang comment}</a>
					</p>
				</li>
			</ol>
			<div id="pager" class="pagination text_c"></div>
			<script type="text/javascript" language="javascript">
			        $(document).ready(function() {
			        	var editor = $.oEditor('r_editor',{
			        		id : 'r_editor', 
			        		className : 'editor',
			        		initialtext : '',
			        		editorcurrentheight : 100, 
			        		editorminheight : 100,
			        		editorcontroltop:false,
			        		editorid : 'reditor'
			        	});
		  				{if $store['totalcomments']>0}
			            var totalPages = Math.ceil(Number({$store['totalcomments']})/5);
			            var sid = {$store["store_id"]};
			            $("#pager").pager({ pagenumber: 1, pagecount: totalPages, buttonClickCallback: PageClick });
			
			            function PageClick(pageclickednumber) {
			                $("#pager").pager({ pagenumber: pageclickednumber, pagecount: totalPages, buttonClickCallback: PageClick });
							var tpl_e = $('#comment_store_tpl');
							var data = {'storeid' : sid,'page' : pageclickednumber};
							ajaxpost('{url comment/getstorecomments}', data, 
								function(result){
									var new_comment = $(Mustache.to_html(tpl_e.html(), result));
									$('#' + sid + '_storecomments').html(new_comment);
									new_comment.fadeIn(50);
									$('#' + sid + '_commentbox').val('');
								},
								function(result){
									show_message('error',tip_error+' : '+$.trim(result.message),false,0);
								});
			            }
			            PageClick(1);
						{/if}
			         });
			    </script>
		</div>
		{template js_tpl/comment_store_tpl}
		</div>
	</div>
</div>
{template common/footer}